package com.hangjiang.gulidear.model;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator;

/**
 * Task entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "task", catalog = "sqm")
public class Task extends BaseEntity {

	// Fields

	private String taskId;
	private Project project;
	private User userByExecutionUserId;
	private ConfigIssue configissue;
	private Bug bug;
	private User userByCreateUserId;
	private String taskName;
	private Timestamp taskTime;
	private String taskDescribe;
	private Date deadline;
	private Integer priority;
	private Integer status;
	private Set<ConfigChange> configchanges = new HashSet<ConfigChange>(0);
	private Set<BugSolution> bugsolutions = new HashSet<BugSolution>(0);

	// Constructors

	/** default constructor */
	public Task() {
	}

	/** full constructor */
	public Task(Project project, User userByExecutionUserId,
			ConfigIssue configissue, Bug bug, User userByCreateUserId,
			String taskName, Timestamp taskTime, String taskDescribe,
			Date deadline, Integer priority, Integer status) {
		this.project = project;
		this.userByExecutionUserId = userByExecutionUserId;
		this.configissue = configissue;
		this.bug = bug;
		this.userByCreateUserId = userByCreateUserId;
		this.taskName = taskName;
		this.taskTime = taskTime;
		this.taskDescribe = taskDescribe;
		this.deadline = deadline;
		this.priority = priority;
		this.status = status;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "taskId", unique = true, nullable = false, length = 32)
	public String getTaskId() {
		return this.taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "projId")
	public Project getProject() {
		return this.project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = " executionUserId")
	public User getUserByExecutionUserId() {
		return this.userByExecutionUserId;
	}

	public void setUserByExecutionUserId(User userByExecutionUserId) {
		this.userByExecutionUserId = userByExecutionUserId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "issueId")
	public ConfigIssue getConfigissue() {
		return this.configissue;
	}

	public void setConfigissue(ConfigIssue configissue) {
		this.configissue = configissue;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "bugId")
	public Bug getBug() {
		return this.bug;
	}

	public void setBug(Bug bug) {
		this.bug = bug;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "createUserId")
	public User getUserByCreateUserId() {
		return this.userByCreateUserId;
	}

	public void setUserByCreateUserId(User userByCreateUserId) {
		this.userByCreateUserId = userByCreateUserId;
	}

	@Column(name = "taskName", length = 30)
	public String getTaskName() {
		return this.taskName;
	}

	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}

	@Column(name = "taskTime", length = 0)
	public Timestamp getTaskTime() {
		return this.taskTime;
	}

	public void setTaskTime(Timestamp taskTime) {
		this.taskTime = taskTime;
	}

	@Column(name = "taskDescribe", length = 200)
	public String getTaskDescribe() {
		return this.taskDescribe;
	}

	public void setTaskDescribe(String taskDescribe) {
		this.taskDescribe = taskDescribe;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "deadline", length = 0)
	public Date getDeadline() {
		return this.deadline;
	}

	public void setDeadline(Date deadline) {
		this.deadline = deadline;
	}

	@Column(name = "priority")
	public Integer getPriority() {
		return this.priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "task")
	public Set<ConfigChange> getConfigchanges() {
		return this.configchanges;
	}

	public void setConfigchanges(Set<ConfigChange> configchanges) {
		this.configchanges = configchanges;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "task")
	public Set<BugSolution> getBugsolutions() {
		return this.bugsolutions;
	}

	public void setBugsolutions(Set<BugSolution> bugsolutions) {
		this.bugsolutions = bugsolutions;
	}

}